const Router = require("koa-router");
const {
  register,
  login,
  getUserInfo,
  updatePwd,
} = require("../controller/user.controller");
const {
  userValidator,
  crpytPassword,
  verifyAppLogin,
} = require("../middleware/user.middleware");
const { auth } = require("../middleware/auth.middleware");
const appUserRouter = new Router({ prefix: "/appUser" });

appUserRouter.get("/", (ctx, next) => {
  // ctx.router available
  ctx.body = "hello user1";
});
// 用户注册接口
appUserRouter.post("/register", userValidator, crpytPassword, register);

// 用户登录
appUserRouter.post("/login", verifyAppLogin, login);

// 获取用户信息
appUserRouter.get("/getUserInfo", auth);

module.exports = appUserRouter;
